/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.iec.edp.caf.msu.common;

import io.iec.edp.caf.commons.utils.SpringBeanUtils;
import io.iec.edp.caf.msu.api.ServiceUnitAwareService;
import io.iec.edp.caf.sumgr.api.IServiceUnitAware;
import io.iec.edp.caf.sumgr.api.entity.ServiceUnitInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * 已作废，请使用{@link io.iec.edp.caf.msu.api.ServiceUnitAwareService} 替换
 * 无法删除：被 {@link com.inspur.edp.dataie.rpc.client.DataIeRestServiceImpl} 依赖
 *
 * @author Leon Huo
 * @Date: 2021/5/12
 */
@Deprecated
public class ServiceUnitAwareImpl implements IServiceUnitAware {

    private static final ServiceUnitAwareService suService = SpringBeanUtils.getBean(ServiceUnitAwareService.class);

    @Override
    public List<ServiceUnitInfo> getAllServiceUnits() {
        List<io.iec.edp.caf.msu.api.entity.ServiceUnitInfo> suInfos = suService.getAllServiceUnits();
        List<ServiceUnitInfo> result = new ArrayList<>();
        suInfos.forEach(info -> {
            result.add(new ServiceUnitInfo(info));
        });
        return result;
    }

    @Override
    public List<String> getEnabledServiceUnits() {
        return suService.getEnabledServiceUnits();
    }

}
